package cn.wolfcode.cloud.productserver.mapper;


import cn.wolfcode.cloud.productapi.domian.Product;
import org.springframework.stereotype.Component;

import java.util.*;

@Component
public class ProductMapper {

    private Map<Long,Product> map = new HashMap<>();

    public ProductMapper(){
        map.put(1L,new Product(1L,"小米",1999,1));
        map.put(2L,new Product(2L,"华为",1999,2));
        map.put(3L,new Product(3L,"魅族",1999,3));
        map.put(4L,new Product(4L,"苹果",1999,4));
        map.put(5L,new Product(5L,"锤子",1999,5));
    }

    public List<Product> list(){
        List<Product> list = new ArrayList<>(map.values());
        return list;
    }

    public Product find(Long userId){
        return map.get(userId);
    }


}
